package com.graduation.fq.teacher.process;

import com.graduation.fq.teacher.module.CourseInfo;

import org.json.JSONObject;

/**
 * @author jifang
 * @version 2016/5/22.
 */
public class CourseInfoAddProcess extends BaseProcess {
    private String url = "/course/add_course.do?";
    private CourseInfo info;

    public CourseInfo getInfo() {
        return info;
    }

    public void setInfo(CourseInfo info) {
        this.info = info;
    }

    @Override
    String getRequestUrl() {
        String appurl = new StringBuilder("name=").append(info.getName()).append("&credit=")
                .append(String.valueOf(info.getCredit())).append("&t_id=").
                        append(info.getTeacherId()).toString();
        return url + appurl;
    }

    @Override
    String getParameter() {
        return null;
    }

    @Override
    void onResult(JSONObject object) {
        int statusCode = object.optInt("status");
        setStatus(statusCode);
    }
}
